package com.huitone.gddw.service.impl.monitoring.environment;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.huitone.gddw.common.ComConstant;
import com.huitone.gddw.dao.monitoring.environment.IRedisMonitorDao;
import com.huitone.gddw.model.support.QueryPage;
import com.huitone.gddw.service.dto.monitoring.environment.EnvDTO;
import com.huitone.gddw.service.dto.monitoring.environment.RedisMonitorDTO;
import com.huitone.gddw.service.monitoring.environment.IRedisMonitorService;

/**
 * redis监控
 * @author wuluodan
 *
 */
@Service
public class RedisMonitorService implements IRedisMonitorService {

	@Autowired
	private IRedisMonitorDao redisMonitorDao;
	
	@Override
	public List<EnvDTO> findRedisCluster() {
		Map<String, Object> params = new HashMap<>();
		params.put("objType", ComConstant.REDIS_CLUS);
		params.put("itemName", ComConstant.CLUSTER);
		return null;
	}

	@Override
	public QueryPage<EnvDTO> selectPage(QueryPage<RedisMonitorDTO> page) {
		Map<String, Object> params = page.getParams();
		params.put("start", (page.getPageNo() - 1) * page.getPageSize() + 1);
		params.put("end", page.getPageNo() * page.getPageSize());
		
		List<EnvDTO> result = redisMonitorDao.selectPage(params);
		int totalCount = redisMonitorDao.selectCount(params);
		
		QueryPage<EnvDTO> queryPage = new QueryPage<EnvDTO>();
		queryPage.setResult(result);
		queryPage.setPageNo(page.getPageNo());
		queryPage.setPageSize(page.getPageSize());
		queryPage.setTotalCount(totalCount);
		return queryPage;
	}

	@Override
	public List<EnvDTO> getRecord(Map<String, Object> params) {
		// TODO Auto-generated method stub
		return null;
	}

}
